change return type get_cache_icon, gs_get_cachetype, gs_get_container to QString...
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 31 Jul 2022 19:35:03 +0000 (13:35 -0600)
committerGitHub <noreply@github.com>
Sun, 31 Jul 2022 19:35:03 +0000 (13:35 -0600)
defs.h
garmin.cc
gpx.cc
html.cc
lowranceusr.cc
magproto.cc
text.cc
util.cc
xcsv.cc

diff --git a/defs.h b/defs.h
index 352c65a334d11094f6a7e8531fb9453265e6da71..d576ff683423cc7007a217f703eeef9ad50e8473 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -1076,9 +1076,9 @@ time_t mkgmtime(struct tm* t);
 bool gpsbabel_testmode();
 gpsbabel::DateTime current_time();
 QDateTime dotnet_time_to_qdatetime(long long dotnet);
-const char* get_cache_icon(const Waypoint* waypointp);
-const char* gs_get_cachetype(geocache_type t);
-const char* gs_get_container(geocache_container t);
+QString get_cache_icon(const Waypoint* waypointp);
+QString gs_get_cachetype(geocache_type t);
+QString gs_get_container(geocache_container t);
 QString xml_entitize(const QString& str);
 QString html_entitize(const QString& str);
 char* strip_html(const utf_string*);
index f1e188ba3615512bb7b9f27480d256c346a8756c..38d54e51aae5938b9076e6ec24c09f3dc6de8089 100644 (file)
--- a/garmin.cc
+++ b/garmin.cc
@@ -986,7 +986,7 @@ waypoint_prepare()
     if (deficon) {
       icon = gt_find_icon_number_from_desc(deficon, PCX);
     } else {
-      if (get_cache_icon(wpt)) {
+      if (!get_cache_icon(wpt).isEmpty()) {
         icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
       } else {
         icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
diff --git a/gpx.cc b/gpx.cc
index b6803bf78a7e5ebfc82d12df1f2670b43de0a64b..a54b7359464428f69a3d81172bb13f21321195b1 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -442,7 +442,7 @@ gs_mktype(const QString& t)
   return gt_unknown;
 }
 
-const char*
+QString
 gs_get_cachetype(geocache_type t)
 {
   int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
@@ -468,7 +468,7 @@ gs_mkcont(const QString& t)
   return gc_unknown;
 }
 
-const char*
+QString
 gs_get_container(geocache_container t)
 {
   int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
diff --git a/html.cc b/html.cc
index e84507f7117a086ed3a9bd11d05d42b907bc3e18..ddf0b81c1df065dedb022cf0159c609182e26bf5 100644 (file)
--- a/html.cc
+++ b/html.cc
@@ -90,11 +90,12 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
   gbfprintf(file_out, "<td align=\"right\">");
   if (wpt->gc_data->terr) {
     gbfprintf(file_out, "<p class=\"gpsbabelcacheinfo\">%d%s / %d%s<br>\n",
-              (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?"&frac12;":"",
-              (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?"&frac12;":"");
-    gbfprintf(file_out, "%s / %s</p>",
-              gs_get_cachetype(wpt->gc_data->type),
-              gs_get_container(wpt->gc_data->container));
+              (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10) ? "&frac12;" : "",
+              (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10) ? "&frac12;" : "");
+    gbfputs(QStringLiteral("%1 / %2</p>")
+            .arg(gs_get_cachetype(wpt->gc_data->type),
+                 gs_get_container(wpt->gc_data->container)),
+            file_out);
   }
   gbfprintf(file_out, "</td></tr>\n");
 
index 03cb3844296b01e2390d11d4e363d9825eb3e24f..de18681bfce168a9c8f4c3d610a9ea34d01d25be 100644 (file)
@@ -1346,7 +1346,7 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const
 
   gbfputint32(waypt_time, file_out);
 
-  if (get_cache_icon(wpt) && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) {
+  if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) {
     SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
   } else {
     SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
@@ -1407,7 +1407,7 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt)
   gbfputint32(2, file_out);
 
   int SymbolId, ColorId;
-  if (get_cache_icon(wpt) && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) {
+  if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) {
     if (writing_version == 4) {
       SymbolId = lowranceusr4_find_icon_number_from_desc(wpt->icon_descr);
     } else {
index e5a278f29b7802a1d4b6b47335375ad121a7e7dc..77380bb017fbbbe2b227af9229a0463c58a0317f 100644 (file)
@@ -1359,7 +1359,7 @@ mag_waypt_pr(const Waypoint* waypointp)
     icon_token = mag_find_token_from_descr(waypointp->icon_descr);
   }
 
-  if (get_cache_icon(waypointp)) {
+  if (!get_cache_icon(waypointp).isEmpty()) {
     icon_token = mag_find_token_from_descr(get_cache_icon(waypointp));
   }
 
diff --git a/text.cc b/text.cc
index 313c379c078785702330a4edec2cf0e14f38b18d..42fa2b45693b43b96bb826ed817dc5e8969f5e79 100644 (file)
--- a/text.cc
+++ b/text.cc
@@ -101,10 +101,14 @@ TextFormat::text_disp(const Waypoint* wpt)
     }
   }
   if (wpt->gc_data->terr) {
-    gbfprintf(file_out, " - %s / %s - (%d%s / %d%s)\n",
-              gs_get_cachetype(wpt->gc_data->type), gs_get_container(wpt->gc_data->container),
-              (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?".5":"",
-              (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?".5":"");
+    gbfputs(QStringLiteral(" - %1 / %2 - (%3%4 / %5%6)\n")
+            .arg(gs_get_cachetype(wpt->gc_data->type),
+                 gs_get_container(wpt->gc_data->container))
+            .arg((int)(wpt->gc_data->diff / 10))
+            .arg((wpt->gc_data->diff%10) ? ".5" : "")
+            .arg((int)(wpt->gc_data->terr / 10))
+            .arg((wpt->gc_data->terr%10) ? ".5" : ""),
+            file_out);
     if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
       char* stripped_html = strip_html(&wpt->gc_data->desc_short);
       gbfprintf(file_out, "\n%s\n", stripped_html);
diff --git a/util.cc b/util.cc
index b722ee00deb77389f970f235bf182de219abeb88..7c7eddbad45faa1366a332c930d70049d1a29dac 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -724,7 +724,7 @@ QDateTime dotnet_time_to_qdatetime(long long dotnet)
  * a GPX file from geocaching.com.  Thus we sort of make all the other
  * formats do lookups based on these strings.
  */
-const char*
+QString
 get_cache_icon(const Waypoint* waypointp)
 {
   if (!global_opts.smart_icons) {
diff --git a/xcsv.cc b/xcsv.cc
index 8adc85cb944b69b7aaba188c9da1a187a4486fe7..0c9d3e19e8fc4ff12350de1232edb629dd6d6e82 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -1388,12 +1388,12 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
       break;
     case XcsvStyle::XT_GEOCACHE_CONTAINER:
       /* Geocache Container */
-      buff = QString::asprintf(fmp.printfc.constData(), gs_get_container(wpt->gc_data->container));
+      buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_container(wpt->gc_data->container)));
       field_is_unknown = wpt->gc_data->container == gc_unknown;
       break;
     case XcsvStyle::XT_GEOCACHE_TYPE:
       /* Geocache Type */
-      buff = QString::asprintf(fmp.printfc.constData(), gs_get_cachetype(wpt->gc_data->type));
+      buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_cachetype(wpt->gc_data->type)));
       field_is_unknown = wpt->gc_data->type == gt_unknown;
       break;
     case XcsvStyle::XT_GEOCACHE_HINT: